package com.db.stockexchange.demo;

import java.io.IOException;

import com.db.stockexchange.network.RequestListener;
import com.db.stockexchange.network.Server;
import com.db.stockexchange.network.Server.Connection;

public class EchoServer {
	public static void main(String[] args) {
		Server server = new Server();

		server.addRequestListener(new RequestListener() {

			@Override
			public void requestReceived(byte[] message, Connection connection) {
				try {
					String request = new String(message);
					connection.write(request.toUpperCase().getBytes());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		});

		(new Thread(server)).start();
	}
}
